//
//  FilledShape.swift
//  SwiftUIShape
//
//  Created by 李煜 on 2024/7/31.
//

import SwiftUI

struct FilledShape: View {
  var body: some View {
    //画一个矩形
    Path({ path in
      path.addRect(CGRect(x: 0, y: 0, width: 50, height: 100))
    })
    .fill(.green)
    
    
    
    // 画一个椭圆
    Path { p in
      p.addEllipse(in: CGRect(x: 100, y: 100, width: 200, height: 40))
    }
    .fill(.purple)
    
    // 形状
    Path({ path in
      path.move(to: CGPoint(x: 20, y: 20))
      path.addLine(to: CGPoint(x: 50, y: 20))
      //画曲线
      path.addQuadCurve(to: CGPoint(x: 100, y: 120), control: CGPoint(x: 120, y: 10))
      //画直线
      path.addLine(to: CGPoint(x: 300, y: 120))
      //画弧线
      path.addArc(center: CGPoint(x: 300, y: 150), radius: 80, startAngle: .degrees(0), endAngle: .degrees(9), clockwise: true)
      path.addLine(to: CGPoint(x: 20, y: 200))
    })
    .fill(.orange)
  }
}

#Preview {
  FilledShape()
}
